performance.getEntriesByType(‘navigation’):
performance.getEntriesByType(‘paint’): first-paint, first-contentful-paint
2020.10.23 星期五 21:12
Performance
# Performance
Performance 接口可以获取到当前页面中与性能相关的信息。它是 High Resolution Time API 的一部分,同时也融合了 Performance Timeline API、Navigation Timing API、 User Timing API 和 Resource Timing API。
该类型的对象可以通过调用只读属性 Window.performance 来获得。
注意:除了以下指出的情况外,该接口及其成员在 Web Worker 中可用。此外,还需注意,performance 的创建和衡量都是同一环境下的。即,如果你在主线程(或者其他 worker)中创建了一个 performance,那么它在另外的 worker 线程中是不可用的;反之亦然
$_PS: window.performance: eventCounts, memory,navigation,onresourcetimingbufferfull, timeOrigin, timingPerformance.navigationPerformance.timing
方法: Performance 接口没有继承任何方法。
clearMarks(), clearMeasures(), || .mark(), measure(), now(), toJSON()
getEntries(), getEntriesByType(),
Performance API
## PerformanceEntry
PerformanceEntry instances will always be one of the following subtypes:
PerformanceMark
PerformanceMeasure
PerformanceFrameTiming
PerformanceNavigationTiming
PerformanceResourceTiming
PerformancePaintTiming
Properties: name, entryType, startTime, duration
Methods: toJSON()
## PerformanceEntry.entryType
Performance entry type names:
frame, navigation; resource; mark; measure; paint; longtask
$_PS: 和上面的6种实例相对应
This interface is deprecated in the Navigation Timing Level 2 specification. Please use the PerformanceNavigationTiming interface instead.